import 'dart:async';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:event_bus/event_bus.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:package_info/package_info.dart';
import 'package:thinking/config/_.dart';
import 'package:thinking/utils/_.dart';


class Configure{

  static Future init() async{
    ///运行初始
    WidgetsFlutterBinding.ensureInitialized();

    ///指定屏幕方向
    SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);

    ///初始化 SPreferences
   await SPreferences.init();

    ///检查是否进入过app
   Config.isOpened =  SPreferences().getBool('isOpened',true)!;

    ///检查是否登录过
    SPreferences().getBool('isLogin', false);

    ///修改状态栏字体颜色
    Core.setStatusThemeColor(color:Colors.transparent,textColor: 'Light',isBarColor: true);

    ///初始化事件控制中心
    Config.eventBus = EventBus();

    /// 读取保存设备信息
    DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
    Config.isAndroid
        ? Config.androidDeviceInfo = await deviceInfoPlugin.androidInfo
        : Config.iosDeviceInfo = await deviceInfoPlugin.iosInfo;

    /// 保存App软件包信息
    Config.packageInfo = await PackageInfo.fromPlatform();

    // print('Running on ${Config.androidDeviceInfo.model}');


  }

}